#include <iostream>

using namespace std;

int main() {
    constexpr int target = 678910;
    constexpr int prefix = 123;
    constexpr int moduls = 1000;
    long double d = 1;
    int64_t r = 0;
    for (int i = 0; i < target; ++r) {
        d *= 2;
        if (d > moduls)
            d /= 10.0;
        if (static_cast<int>(d) == prefix)
            ++i;
    }
    cout << r << endl;
}   // 193060223